-
Notifications
You must be signed in to change notification settings - Fork 0
43 update component tests for apollo #67
Conversation
The detail page now queries the sighting by id instead of reading the mock data. Part of #35
Nothing reads from the store now that the detail page uses GraphQL, so SubmitSightingPage no longer adds sightings to it. The mock sightings move to tests/ because the tests still use them as fixtures.
Give the fake backend an optional latency so states that only exist while waiting can be tested, and test the first load, a serach with no matches and a new serach while old results are shown. Refs #43
Clear the cached sighting lists after a submit so the new sighting shows up in the search results. Show "Unknown" for a missing shape and hide empty comments. Return "Unknown date" for invalid dates instead of throwing. Return not found for ids that are not plain numbers, since MySQL reads '1abc' as 1. Part of #35
The detail page said "Check your connection" for every error. If the backend answers with a GraphQL error, such as a database failure, it now says the server could not load the sighting and hides the retry button, since retrying won't help. Network failures keep the old message and the button. Part of #35
…e-backen' into 43-update-component-tests-for-apollo
The summary counted keys in the errors object, but fixing a field set its error to undefined without removing the key. Now it checks for actual messages instead. Fixes #63
Check that an invalid form sends no request and links each error to its feild, that the error summary goes away once the fileds are fixed, that a double click sends on requests, and that a sbmitted sighting shows up in the search list. Uses a fake database that stores the sighting and counts requests. Refs #43, #64
npm test started Vitest in watch mode and only reached the backend tests after quitting it. Run Vitest once by default, like CI, and moved watch mode to npm run test:watch. Documented in AGENTS.md. Refs #43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran npm test locally and got ERR_UNKNOWN_FILE_EXTENSION when Node tried to run the backend .ts test file. Could you update the backend test script to run through tsx so it works consistently across Node versions?
node --test only runs .ts files by itself from Node 22.18, so npm test failed with ERR_UNKNOWN_FILE_EXTENSION on older Node 22 version. Now the tests are ran through tsx instead, and Node 22 is set as the minimum version in package.json. Refs #43
Good catch! Could you run npm test again to confirm? It should work now. |
It works now, good job. |
The merge-base changed after approval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved
The merge-base changed after approval.
The merge-base changed after approval.
Component tests with mocked Apollo
Builds on #35. Must Merge #35 first! Until then, this PR also shows its commits.
All component tests now run without a backend.
npm testnow runs all tests once, like CI. Watch mode moved tonpm run test:watch. Before,npm testhung in watch mode and only ran the backend tests after you pressedq.How to test
npm test: 50 frontend and 10 backend tests should pass, with no backend running.AI usage
Claude Code helped write the tests, find and fix #63, and change the test scripts.
Closes #43